Optimal. Leaf size=121 \[ a^2 (2 A+B) x+\frac {a^2 (2 A+4 B+3 C) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}-\frac {a^2 (2 A-2 B-3 C) \tan (c+d x)}{2 d}-\frac {(2 A-C) \left (a^2+a^2 \sec (c+d x)\right ) \tan (c+d x)}{2 d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.15, antiderivative size = 121, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 39, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.154, Rules used = {4171, 4002,
3999, 3852, 8, 3855} \begin {gather*} -\frac {a^2 (2 A-2 B-3 C) \tan (c+d x)}{2 d}+\frac {a^2 (2 A+4 B+3 C) \tanh ^{-1}(\sin (c+d x))}{2 d}+a^2 x (2 A+B)-\frac {(2 A-C) \tan (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{2 d}+\frac {A \sin (c+d x) (a \sec (c+d x)+a)^2}{d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 8
Rule 3852
Rule 3855
Rule 3999
Rule 4002
Rule 4171
Rubi steps
\begin {align*} \int \cos (c+d x) (a+a \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx &=\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}+\frac {\int (a+a \sec (c+d x))^2 (a (2 A+B)-a (2 A-C) \sec (c+d x)) \, dx}{a}\\ &=\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}-\frac {(2 A-C) \left (a^2+a^2 \sec (c+d x)\right ) \tan (c+d x)}{2 d}+\frac {\int (a+a \sec (c+d x)) \left (2 a^2 (2 A+B)-a^2 (2 A-2 B-3 C) \sec (c+d x)\right ) \, dx}{2 a}\\ &=a^2 (2 A+B) x+\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}-\frac {(2 A-C) \left (a^2+a^2 \sec (c+d x)\right ) \tan (c+d x)}{2 d}-\frac {1}{2} \left (a^2 (2 A-2 B-3 C)\right ) \int \sec ^2(c+d x) \, dx+\frac {1}{2} \left (a^2 (2 A+4 B+3 C)\right ) \int \sec (c+d x) \, dx\\ &=a^2 (2 A+B) x+\frac {a^2 (2 A+4 B+3 C) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}-\frac {(2 A-C) \left (a^2+a^2 \sec (c+d x)\right ) \tan (c+d x)}{2 d}+\frac {\left (a^2 (2 A-2 B-3 C)\right ) \text {Subst}(\int 1 \, dx,x,-\tan (c+d x))}{2 d}\\ &=a^2 (2 A+B) x+\frac {a^2 (2 A+4 B+3 C) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {A (a+a \sec (c+d x))^2 \sin (c+d x)}{d}-\frac {a^2 (2 A-2 B-3 C) \tan (c+d x)}{2 d}-\frac {(2 A-C) \left (a^2+a^2 \sec (c+d x)\right ) \tan (c+d x)}{2 d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(365\) vs. \(2(121)=242\).
time = 3.68, size = 365, normalized size = 3.02 \begin {gather*} \frac {a^2 \cos ^4(c+d x) \sec ^4\left (\frac {1}{2} (c+d x)\right ) (1+\sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \left (4 (2 A+B) x-\frac {2 (2 A+4 B+3 C) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )}{d}+\frac {2 (2 A+4 B+3 C) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )}{d}+\frac {4 A \cos (d x) \sin (c)}{d}+\frac {4 A \cos (c) \sin (d x)}{d}+\frac {C}{d \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {4 (B+2 C) \sin \left (\frac {d x}{2}\right )}{d \left (\cos \left (\frac {c}{2}\right )-\sin \left (\frac {c}{2}\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )}-\frac {C}{d \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {4 (B+2 C) \sin \left (\frac {d x}{2}\right )}{d \left (\cos \left (\frac {c}{2}\right )+\sin \left (\frac {c}{2}\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )}\right )}{8 (A+2 C+2 B \cos (c+d x)+A \cos (2 (c+d x)))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.80, size = 155, normalized size = 1.28
method | result | size |
derivativedivides | \(\frac {a^{2} A \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} B \tan \left (d x +c \right )+a^{2} C \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+2 a^{2} A \left (d x +c \right )+2 a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 a^{2} C \tan \left (d x +c \right )+a^{2} A \sin \left (d x +c \right )+a^{2} B \left (d x +c \right )+a^{2} C \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}\) | \(155\) |
default | \(\frac {a^{2} A \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} B \tan \left (d x +c \right )+a^{2} C \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+2 a^{2} A \left (d x +c \right )+2 a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 a^{2} C \tan \left (d x +c \right )+a^{2} A \sin \left (d x +c \right )+a^{2} B \left (d x +c \right )+a^{2} C \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}\) | \(155\) |
risch | \(2 a^{2} A x +a^{2} B x -\frac {i a^{2} A \,{\mathrm e}^{i \left (d x +c \right )}}{2 d}+\frac {i a^{2} A \,{\mathrm e}^{-i \left (d x +c \right )}}{2 d}-\frac {i a^{2} \left (C \,{\mathrm e}^{3 i \left (d x +c \right )}-2 B \,{\mathrm e}^{2 i \left (d x +c \right )}-4 C \,{\mathrm e}^{2 i \left (d x +c \right )}-C \,{\mathrm e}^{i \left (d x +c \right )}-2 B -4 C \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A}{d}+\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{d}+\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) C}{2 d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A}{d}-\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{d}-\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) C}{2 d}\) | \(260\) |
norman | \(\frac {\left (-2 a^{2} A -a^{2} B \right ) x +\left (-4 a^{2} A -2 a^{2} B \right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (2 a^{2} A +a^{2} B \right ) x \left (\tan ^{8}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (4 a^{2} A +2 a^{2} B \right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\frac {a^{2} \left (2 A -2 B -3 C \right ) \left (\tan ^{7}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}+\frac {a^{2} \left (2 B +3 C +6 A \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {a^{2} \left (2 A +2 B +5 C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}-\frac {a^{2} \left (6 A -2 B -5 C \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right ) \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{3}}-\frac {a^{2} \left (2 A +4 B +3 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d}+\frac {a^{2} \left (2 A +4 B +3 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 d}\) | \(298\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.29, size = 192, normalized size = 1.59 \begin {gather*} \frac {8 \, {\left (d x + c\right )} A a^{2} + 4 \, {\left (d x + c\right )} B a^{2} - C a^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, A a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 4 \, B a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, C a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 4 \, A a^{2} \sin \left (d x + c\right ) + 4 \, B a^{2} \tan \left (d x + c\right ) + 8 \, C a^{2} \tan \left (d x + c\right )}{4 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 1.97, size = 143, normalized size = 1.18 \begin {gather*} \frac {4 \, {\left (2 \, A + B\right )} a^{2} d x \cos \left (d x + c\right )^{2} + {\left (2 \, A + 4 \, B + 3 \, C\right )} a^{2} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (2 \, A + 4 \, B + 3 \, C\right )} a^{2} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, A a^{2} \cos \left (d x + c\right )^{2} + 2 \, {\left (B + 2 \, C\right )} a^{2} \cos \left (d x + c\right ) + C a^{2}\right )} \sin \left (d x + c\right )}{4 \, d \cos \left (d x + c\right )^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} a^{2} \left (\int A \cos {\left (c + d x \right )}\, dx + \int 2 A \cos {\left (c + d x \right )} \sec {\left (c + d x \right )}\, dx + \int A \cos {\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int B \cos {\left (c + d x \right )} \sec {\left (c + d x \right )}\, dx + \int 2 B \cos {\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int B \cos {\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\, dx + \int C \cos {\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int 2 C \cos {\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\, dx + \int C \cos {\left (c + d x \right )} \sec ^{4}{\left (c + d x \right )}\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.50, size = 204, normalized size = 1.69 \begin {gather*} \frac {\frac {4 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1} + 2 \, {\left (2 \, A a^{2} + B a^{2}\right )} {\left (d x + c\right )} + {\left (2 \, A a^{2} + 4 \, B a^{2} + 3 \, C a^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - {\left (2 \, A a^{2} + 4 \, B a^{2} + 3 \, C a^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (2 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 3 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 2 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 5 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{2}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 3.83, size = 244, normalized size = 2.02 \begin {gather*} \frac {\frac {A\,a^2\,\sin \left (3\,c+3\,d\,x\right )}{4}+\frac {B\,a^2\,\sin \left (2\,c+2\,d\,x\right )}{2}+C\,a^2\,\sin \left (2\,c+2\,d\,x\right )+\frac {A\,a^2\,\sin \left (c+d\,x\right )}{4}+\frac {C\,a^2\,\sin \left (c+d\,x\right )}{2}}{d\,\left (\frac {\cos \left (2\,c+2\,d\,x\right )}{2}+\frac {1}{2}\right )}-\frac {2\,\left (-2\,A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,1{}\mathrm {i}-B\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+B\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,2{}\mathrm {i}+\frac {C\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,3{}\mathrm {i}}{2}\right )}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________